/**
 * @description 异步设置本地储存
 * @params { Object }  <o.key> <o.data>
 * */
function set({ key, data }) {
  my.setStorageSync({
    key,
    data: data || {},
  });
}

/**
 * @description 同步获取本地储存
 * @params { Object }  <o.key>
 * */
function get({ key }) {
  let data = my.getStorageSync({
    key,
  });
  if (data && data.data) {
    return data.data;
  }
  return {};
}

/**
 * @description 异步删除本地储存
 * @params { Object }  <o.key> <o.data>
 * */
function remove({ key }) {
  my.removeStorageSync({
    key,
  });
}

/**
 * @description 异步清空缓存
 * @params { Object }  <o.key> <o.data>
 * */
function clear() {
  my.clearStorage({
    success() {
      console.log('清除缓存成功');
    },
  });
}

const CURRENT_COMMODITY_NO = 'CURRENT_COMMODITY_NO';
const ORDER_CACHE_INFO = 'ORDER_CACHE_INFO';

export { set, get, remove, clear, ORDER_CACHE_INFO, CURRENT_COMMODITY_NO };
